﻿using RabbitMQShare;
using System;
using System.Collections.Generic;

namespace RabbitMQCreator
{
    class Program
    {
        /*
         * 生产者 生产数据给服务器消费
         */
        private static RabbitMqModel _rabbitMqModel;
        

        public  static void Main(string[] args)
        {
            _rabbitMqModel = new RabbitMqModel()
            {
                Host = "localhost",
                Port = 5672,
                UserName = "guest",
                PassWord = "guest",
                QueueName = "testQue1",
                ExchangeName= "testExchange"
            };
            RabbitMQUtil.InitFactory(_rabbitMqModel);

            for (int i = 0; i < 1000; i++)
            {
                MessageModel message = new MessageModel()
                {
                    Task_Id = 12222+i,
                    MATENUMBER = "st-1234523123"+i,
                    OPERNUMBER = "GX005",
                    WORKORDERNUMBER = "S12345",
                    QTY = 8,
                    State = 1,
                    Bgein_Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    End_Date = "",
                    Remark = "",
                    Create_Date = "",
                    Create_UserId = "admin",
                    Bar_Code = "#dda1245",
                    AGV_OrderId = 1879,
                    BindingOrder = "0"
                };
                bool result = RabbitMQUtil.SendMsgToServer(message, _rabbitMqModel.QueueName, _rabbitMqModel.ExchangeName,null);
                if (result)
                {
                    Console.WriteLine("发送消息成功");
                    RabbitMQUtil._keys.Add(message.Task_Id);
                }
                else
                    Console.WriteLine("发送消息失败");
            }
            Console.ReadKey();
        }
    }
}
